(function($) {

	$.fn.slide = function(options) {
	
		var defaults = {
			speed: 600,
			interval: 6000,
			start: 1,
			easing: 'easeOutExpo',
		}, 
		settings = $.extend(defaults, options);
	
		return this.each(function(){
			
			obj = $(this);
			var w = $('.slide-item', obj).width();			//get the width of slide-item
			
			$('ul.slide-nav li', obj).click(function(){
				
					var index = $(this).index(),			//get current index 
					last = $(this).siblings().length;		//get the length of siblings
				
				if( index != 0){
					obj.find('.container').animate({
						marginLeft: (0-index*w)
					}, settings.speed, settings.easing);
				} else{
					obj.find('.container').animate({
						marginLeft: 0,
					}, settings.speed, settings.easing);
				}
				
				$('ul.slide-nav li', obj).removeClass('active');
				$(this).addClass('active');
				
			}); //.slide-nav onclick
			
			//set up starting .slide-item
			$('ul.slide-nav li:nth-child('+ settings.start +')', obj).addClass('active');
			$('.container', obj).css('margin-left', 0 - (settings.start-1)*w + 'px');
			
			var ss = setInterval(function(){
				var	last = $('ul.slide-nav li', obj).siblings().length - 1,
					index = $('ul.slide-nav li.active', obj).index();

				$('ul.slide-nav li', obj).removeClass('active');
				if( index < last ) {
					$('ul.slide-nav li:eq('+ parseInt(index+1) +')', obj).addClass('active');
					obj.find('.container').animate({
						marginLeft: (0-(index+1)*w)
					},600,"easeOutExpo");
				} else {
					$('ul.slide-nav li:eq(0)', obj).addClass('active');
					obj.find('.container').animate({
						marginLeft: 0,
					},600,"easeOutExpo");
				}
				
			}, settings.interval);
			
		}); // return this
	
	} // $.fn.slide

} ) (jQuery);